package com.example.oceanbase.config;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
@ConfigurationProperties(prefix = "datasource")
public class DataSourceConfig {

    @Bean
    public DataSource dataSource() {
        HikariConfig config = new HikariConfig();
        config.setJdbcUrl("jdbc:oceanbase://192.168.31.75:2881/oceanbase?useSSL=false&useServerPrepStmts=true&serverTimezone=UTC");
        config.setUsername("demo");
        config.setPassword("123456");
        config.setDriverClassName("com.alipay.oceanbase.jdbc.Driver");
        HikariDataSource dataSource = new HikariDataSource(config);
        return dataSource;
    }
}
